All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sunw.demo.quote.QuoteServerImpl

java.lang.Object
   |
   +----java.rmi.server.RemoteObject
           |
           +----java.rmi.server.RemoteServer
                   |
                   +----java.rmi.server.UnicastRemoteObject
                           |
                           +----sunw.demo.quote.QuoteServerImpl

public class QuoteServerImpl
extends UnicastRemoteObject
implements QuoteServer
The QuoteServer implementation. The QuoteServer object starts a thread that polls a quote source and delivers QuoteEvents to QuoteListeners.

Stock information can be collected from one of two sources: "Local" or "Yahoo". The latter is a real (delayed) data feed that reports quotes in a format that can be easily parsed. The "Local" quote source is just a random number generator. The advantage of the local source is that it can produce quotes quickly, this can make demos more interesting.


Method Index

 o addQuoteListener(QuoteListener)
The specified QuoteListeners quoteChanged method will be called each time new quote data is available.
 o getHttpProxy()
The HTTP proxy host and port number are stored in the System property list under "http.proxyHost" and "http.proxyPort".
 o getQuoteEventRate()
 o getQuoteSource()
 o removeQuoteListener(QuoteListener)
Remove this QuoteListener from the servers internal list.
 o setHttpProxy(HttpProxy)
If the specified host is valid and the port number is positive then set the System properties: "http.proxyHost" and "http.proxyPort".
 o setQuoteEventRate(int)
Sets the quote source polling rate.
 o setQuoteSource(String)
Specify where quote data will come from.

Methods

 o getQuoteEventRate
 public int getQuoteEventRate()
Returns:
the quote source polling rate in seconds
 o setQuoteEventRate
 public void setQuoteEventRate(int x)
Sets the quote source polling rate.

Parameters:
x - the polling rate in seconds
 o addQuoteListener
 public synchronized void addQuoteListener(QuoteListener x) throws RemoteException
The specified QuoteListeners quoteChanged method will be called each time new quote data is available. The QuoteListener object is added to a list of QuoteListeners managed by this server, it can be removed with removeQuoteListener.

Parameters:
l - the QuoteListener
See Also:
removeQuoteListener
 o removeQuoteListener
 public synchronized void removeQuoteListener(QuoteListener x) throws RemoteException
Remove this QuoteListener from the servers internal list. If the QuoteListener isn't on the list, silently do nothing.

Parameters:
l - the QuoteListener
See Also:
addQuoteListener
 o getHttpProxy
 public HttpProxy getHttpProxy() throws RemoteException
The HTTP proxy host and port number are stored in the System property list under "http.proxyHost" and "http.proxyPort". We just combine the two values into a single object here.

Returns:
the HTTP proxy host and port number for this server
See Also:
setHttpProxy
 o setHttpProxy
 public void setHttpProxy(HttpProxy x) throws RemoteException
If the specified host is valid and the port number is positive then set the System properties: "http.proxyHost" and "http.proxyPort". Otherwise throw a RemoteException. The HTTP proxy values only matter if the quote source is "Yahoo", i.e. if we're going to the internet for data.

Parameters:
x - the new values for host and port
See Also:
getHttpProxy
 o getQuoteSource
 public String getQuoteSource() throws RemoteException
Returns:
a string that represents the source for quote data
See Also:
setQuoteSource
 o setQuoteSource
 public void setQuoteSource(String x) throws RemoteException
Specify where quote data will come from. If quoteSource is "Local" then the sunw.demo.LocalQuote is used, it generates moderately random data. If quoteSource is "Yahoo" then the sunw.demo.YahooQuote class is used, it collects quote data from the YahooQuote web site.

Parameters:
x - must be "Yahoo" or "Local"
See Also:
getQuoteSource

All Packages  Class Hierarchy  This Package  Previous  Next  Index